package com.global.emc.spring.exception.handler;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.global.emc.core.exception.IEMCException;

/**   
 *  
 * @Description:  [处理异常视图与对象]
 * @Author:       [Joly_Huang]   
 * @CreateDate:   [2014年2月21日 上午9:39:03]   
 * @UpdateUser:   [Joly_Huang]   
 * @UpdateDate:   [2014年2月21日 上午9:39:03]   
 * @UpdateRemark: [说明本次修改内容]  
 * @Version:      [v1.0] 
 *    
 */
public class ModelAndViewEMCExceptionHandlerManager {
	
	private List<SpringModelAndViewEMCExceptionHandler> modelAndViewEMCExceptionHandlers;
	
	public List<SpringModelAndViewEMCExceptionHandler> getModelAndViewEMCExceptionHandlers() {
		return modelAndViewEMCExceptionHandlers;
	}
	public void setModelAndViewEMCExceptionHandlers(List<SpringModelAndViewEMCExceptionHandler> modelAndViewEMCExceptionHandlers) {
		this.modelAndViewEMCExceptionHandlers = modelAndViewEMCExceptionHandlers;
	}

	public ModelAndView handlerModelAndView(HttpServletRequest request, HttpServletResponse response, Object handlerMethod, IEMCException emcException) {
		ModelAndView modelAndView = new ModelAndView();
		
		if(null == modelAndViewEMCExceptionHandlers)
			return modelAndView;
		
		for(SpringModelAndViewEMCExceptionHandler modelAndViewEMCExceptionHandler : modelAndViewEMCExceptionHandlers){
			if(modelAndViewEMCExceptionHandler.supports(emcException))
				modelAndViewEMCExceptionHandler.handlerModelAndView(modelAndView, emcException);
		}
		
		return modelAndView;
	}


}
